var vm_zhuanjiabiandongdetail_shenhe = new Vue({
	el : "#zhuanjiabiandongdetail_shenhe",
	data : {
		deptid : $("#deptid").val(),		// 单位ID
		userid : $("#userid").val(),		// 单位ID
		username : $("#username").val(),		// 单位ID
		piciid : $("#piciid").val(),		// 专家变动批次ID
		renwuid : $("#renwuid").val(),      // 任务ID

		biandonglist : [],// 专家变动列表custom
		biandongid : '',//变动id
		biandong : {},//变动表

		shiwu : {},
		renwu : {},

		zhuanjialist : [],//本单位专家列表

		shenhejilulist : [],

		//查询用字段
		zhuanjiamingcheng : '',
		biandongleixing : '',
		biandongriqi : '',
		//

		shenheyijian : '',//审核意见

	},
	created : function(){
		var _this = this;

		_this.findShiwu();
		_this.findRenwu();
		_this.bindBiandongList();

	},
	methods : {

		findShiwu:function(){
			var _this = this;

			var biandong_layer = layer.open({type:3});
			$.post('/system/shiwu/findbyzhuanjiabiandongpiciid', {
				zhuanjiabiandongpiciid : _this.piciid,
				rdm : Math.random()
			},function(ppData) {
				layer.close(biandong_layer);

				if (ppData != null) {
					var data = ppData;
					_this.shiwu = data.resultContent;
				}
			},"json");
		},

		findRenwu:function(){
			var _this = this;

			var biandong_layer = layer.open({type:3});
			$.post('/system/renwu/findone', {
				renwuid : _this.renwuid,
				rdm : Math.random()
			},function(ppData) {
				layer.close(biandong_layer);

				if (ppData != null) {
					var data = ppData;
					_this.renwu = data.resultContent;
				}
			},"json");
		},

		// 专家变动列表
		bindBiandongList : function(){
			var _this = this;

			var biandong_layer = layer.open({type:3});
			$.post('/system/zhuanjiabiandongdetail/customlist', {
				biandongpiciid : _this.piciid,
				zhuanjiamingcheng : _this.zhuanjiamingcheng,
				biandongleixing : _this.biandongleixing,
				biandongriqi : _this.biandongriqi,
				rdm : Math.random()
			},function(ppData) {
				layer.close(biandong_layer);

				if (ppData != null) {
					var data = ppData;
					_this.biandonglist = data;
				}
			},"json");
		},

		toDetail : function(ppBiandongitem){
			this.biandong =ppBiandongitem;

			$("#biandongdetailModal").modal();
		},

		toShenhe:function(){
			$("#myModalLabel").html("专家变动情况审核");
			$("#modal-dialog").attr("style","width:1200px;");
			$("#shenheModal").modal();
		},

		//审核
		shenhe:function(ppShenhejieguo){
			var _this = this;
			if (_this.checkInputData(ppShenhejieguo)) {
				var biandong_layer = layer.open({type: 3});
				$.post('/system/renwu/shenhe_biandong', {
					shiwuid: _this.shiwu.shiwuid,
					renwuid: _this.renwuid,
					shenherenid:_this.userid,
					shenheren:_this.username,
					shifoutongguo:ppShenhejieguo,
					shenheyijian:_this.shenheyijian,
					deptid:_this.deptid,
					rdm: Math.random()
				}, function (ppData) {
					layer.close(biandong_layer);
					if (ppData != null) {

						if (ppData.result == "1") {
							layer.open({
								time: 1000,
								btn: [],
								content: "审核成功!",
							});

							_this.refresh();
							$("#shenheModal").modal('hide');

						} else {
							layer.alert(ppData.message);
						}
					}
				}, "json");
			}
		},

		shenheOne:function(biandongitem,ppFlag){
			var _this = this;

			biandongitem.beizhu1 = ppFlag;
			if (biandongitem.beizhu1=='2'&&(biandongitem.beizhu3==''||biandongitem.beizhu3==null)){
				layer.alert("请填写审核意见");
				return false;
			}

			$.post('/system/zhuanjiabiandongdetail/shenheone', {
				id: biandongitem.id,
				shenhejieguo : biandongitem.beizhu1,
				shenheyijian : biandongitem.beizhu3,
				rdm: Math.random()
			}, function (ppData) {
				if (ppData != null) {

					if (ppData.result == "1") {

						_this.bindBiandongList();

					} else {
						layer.alert(ppData.message);
					}
				}
			}, "json");
		},

		//检查项目数据
		checkInputData : function(ppShenhejieguo) {
			if (ppShenhejieguo==2){

				if (!$.trim(this.shenheyijian)) {
					layer.alert("请填写审核意见！");
					return false;
				}
			}

			return true;
		},

		refresh:function(){
			var _this = this;

			//
			_this.findShiwu();
			_this.findRenwu();
			_this.bindBiandongList();
		},

		getDate:function(){
			var _this = this;

			_this.biandong.biandongriqi=$("#biandongriqi").val();
		},


		//审核记录
		showShenhejiluModel:function(){
			var _this = this;

			$("#shenhejiluModalLabel").html("审核记录");
			$("#shenhejiluModal").modal();

			_this.bindShenhejilu();
		},

		bindShenhejilu:function(){
			var _this = this;

			var biandong_layer = layer.open({type:3});
			$.post('/system/renwu/findshenhejilu', {
				shiwuid : _this.shiwu.shiwuid,
				rdm : Math.random()
			},function(ppData) {
				layer.close(biandong_layer);

				if (ppData != null) {
					var data = ppData;
					_this.shenhejilulist = data.resultContent;
				}
			},"json");
		},

	},
})